﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel.Channels;
using System.ServiceModel;
using SlasheneFramework.WCF;

namespace DuplexMsmqShared
{
	public class BindingFactory
	{
		public static Binding Create(Uri baseClient)
		{
			CustomBinding binding = null;

			binding = new CustomBinding(new ListenUriBindingElement()
			{
				ListenUriBaseAddress = baseClient
			}, new CompositeDuplexBindingElement(), new ReplyToBindingElement(), new TextMessageEncodingBindingElement(), CreateMsmqBinding());

			return binding;
		}

		private static MsmqTransportBindingElement CreateMsmqBinding()
		{
			var binding = new MsmqTransportBindingElement();
			binding.MsmqTransportSecurity.MsmqAuthenticationMode = MsmqAuthenticationMode.None;
			binding.MsmqTransportSecurity.MsmqProtectionLevel = System.Net.Security.ProtectionLevel.None;
			binding.UseActiveDirectory = false;
			binding.ExactlyOnce = false;
			return binding;
		}
	}
}
